<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            <h2><a href="#" class="back" onclick="history.go(-1)"/>Setor</h2>
        </ui:define>

        <ui:define name="body">
            <h:form id="secretariaForm" enctype="multipart/form-data">            
                <p:messages id="messages" closable="true" showDetail="true" autoUpdate="true"  />
                <br/>
                <p:panel id="secretariaPanel" styleClass="container_24 clearfix">

                    <p:dataList value="#{managerPesquisarSecretaria.setoresUsuario}" var="item" itemType="disc">
                        <br/>
                        <h2><a href="#">#{item.nome}</a></h2>
                        <p:dataTable emptyMessage="Não há usuários" value="#{managerPesquisarSecretaria.usuarioSetor(item)}" var="u">
                            <p:column headerText="Nome" width="700px;">
                                <h:outputText value="#{u.nome}"/>
                            </p:column>
                            <p:column headerText="Contato" width="20px;">
                                <h:outputText value="#{u.telefone}"/>
                            </p:column>
                            <p:column headerText="Msg" width="10px;">
                                <p:commandButton actionListener="#{managerPesquisarSecretaria.usuarioMensagem(u)}" 
                                                 icon="ui-icon-mail-closed" update=":formPanelDlg:recado" oncomplete="dlg.show();"/><br/>

                            </p:column>
                        </p:dataTable>
                        <!--                        <ui:repeat value="{managerPesquisarSecretaria.usuarioSetor(item)}" var="u">
                                                    <h:outputText value="- {u.nome} {u.telefone} " style=" font-size: 18px; padding-left: 10px;"/>
                                                    <p:commandButton  icon="ui-icon-mail-closed" oncomplete="dlg.show();"/><br/>
                                                </ui:repeat>-->
                    </p:dataList>
                    <br/>
                    <center>
                        <p:button value="Voltar" icon="ui-icon-circle-arrow-w" href="indexsecretaria.xhtml" />
                    </center>
                </p:panel>

                <p:blockUI id="BLOCK" block=":formPanelDlg:idb" trigger=":formPanelDlg:idb" > 
                    <p:graphicImage value="media/images/ajax-loader.gif"/>
                </p:blockUI> 
            </h:form>
            <h:form id="formPanelDlg">
                <p:panel id="paneldlg">
                    <p:dialog id="iddlg" header="Caixa de Mensagem" widgetVar="dlg" modal="false"
                              showEffect="fade" hideEffect="fade" width="500" resizable="false" height="20">  
                        <h:outputText id="recado" value="Digite um recado para #{managerPesquisarSecretaria.usuarioMsg}" /> <br/> 
                        <f:facet name="footer">
                            <p:inputTextarea value="#{managerPesquisarSecretaria.usuarioMsg.msg}" /> 
                            <center>
                                <p:commandButton value="Enviar Msg" id="idb"
                                                 update="@form" 
                                                 icon="ui-icon-check"
                                                 actionListener="#{managerPesquisarSecretaria.enviandoEmail()}"
                                                 />
                                <p:commandButton value="Cancelar" process="@this" onclick="dlg.hide()" icon="ui-icon-close" />
                            </center>


                        </f:facet>
                    </p:dialog>   
                </p:panel>

            </h:form>
        </ui:define>
    </ui:composition>
</html>


